/*导航搜索栏*/
var search = document.querySelector('.search-text');
var hotWords = document.querySelector('.hot-words');
if(document.body.offsetWidth>'668'){
	search.onclick=function () {
		hotWords.style.display = 'none'
	}
	search.onblur=function () {
		if(search.value == ''){
			hotWords.style.display = 'block'
		}else{
			hotWords.style.display = 'none'
		}
	}
}

/*head满屏选项卡*/
var index = 0;
var timer = null;
var item = document.querySelectorAll('.nav-item');
var liBoxWrap = document.querySelector('.li-box-wrap')
var itemBox = document.querySelectorAll('.li-box');
for (var i = 0; i < 5; i++) {
	item[i].index = i;
	item[i].onmouseover = function() {
		var that=this;
		for (var j = 0; j < 5; j++) {
			itemBox[j].style.display = 'none';
		}
		itemBox[that.index].style.display = 'block';
		liBoxWrap.style.height = '230px';
		liBoxWrap.style.borderColor = '#e0e0e0'
	}
	item[i].onmouseout = function(){
		for (var j = 0; j < 5; j++) {
			itemBox[j].style.display = 'none';
		}
		liBoxWrap.style.height = '0';
		liBoxWrap.style.borderColor = '#fff';
		clearTimeout(timer)
	}
	itemBox[i].onmousemove = function(){
		this.style.display = 'block';
		liBoxWrap.style.height = '230px';
		liBoxWrap.style.borderColor = '#e0e0e0'
	}
	itemBox[i].onmouseout = function(){
		this.style.display = 'none';
		liBoxWrap.style.height = '0';
		liBoxWrap.style.borderColor = '#fff'
	}
}



/*Top返回顶部*/
var toTop = document.querySelector("#toTop");
window.onscroll=function(){
	if(document.documentElement.scrollTop > 600 || document.body.scrollTop > 600){
		toTop.style.display = 'block'
	}else{
		toTop.style.display = 'none'
	}
}
toTop.addEventListener('click',function(){
	if(document.documentElement.scrollTop > 600){
		window.scrollTo({
			top: 0,
			behavior: 'smooth'
		})
	}else{
		window.scrollTo(0,0)
	}
})


/*移动端的js*/
if(document.body.offsetWidth<='668'){
	var navBtn = document.querySelector('.head-top-phone .left img');
	var navUl = document.querySelectorAll('.topbar-nav');
	var sousuo = document.querySelector('.sousuo');
	var search = document.querySelector('.search');
	var me = document.querySelector('.me');
	navBtn.onclick=function(){
		if(navUl[0].style.height == '13rem'){
			navUl[0].style.height = '0';
		}else{
			navUl[0].style.height = '13rem';
			navUl[1].style.height = '0';
			search.style.height = '0';
		}
	}
	sousuo.onclick=function(){
		if(search.style.height == '3.125rem'){
			search.style.height = '0';
		}else{
			search.style.height = '3.125rem';
			navUl[0].style.height = '0';
			navUl[1].style.height = '0';
		}
	}
	me.onclick=function(){
		if(navUl[1].style.height == '6rem'){
			navUl[1].style.height = '0';
		}else{
			navUl[1].style.height = '6rem';
			navUl[0].style.height = '0';
			search.style.height = '0';
		}
	}
}